//思路：


import java.sql.Array;
import java.util.*;

public class Solution {
    public static void main(String[] args) {
         Scanner in=new Scanner(System.in);
         String s=in.next();
         int n=in.nextInt();
         String s1=s.substring(0,s.length()-n);
         String s2=s.substring(s.length()-n,s.length());
        System.out.println(s2+s1);

    }

}













